package com.study.flink.datastream

import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}

/**
  * Union
  *
  * @author stephen
  * @date 2019-07-19 17:09
  */
object FlinkUnionDemo {

  def main(args: Array[String]): Unit = {
    // 1、执行环境
    val env = StreamExecutionEnvironment.getExecutionEnvironment

    // 2、指定数据源
    import org.apache.flink.api.scala._
    val dataStream1: DataStream[String] = env.fromCollection(List("a", "b", "c", "d"))
    val dataStream2: DataStream[String] = env.fromElements("1","2","3","4")

    // 3 处理
    val unionStream = dataStream1.union(dataStream2)
    unionStream.print()

    // 4 启动任务
    env.execute("Flink Connect Demo")
  }
}
